Skip to content

Add GRPC + TLS integration tests (notably, test important security properties) - #1327

Closed
matthild wants to merge 6 commits into
grpc:masterfrom
matthild:matthild_tls_client_auth_test_v3
Closed

Add GRPC + TLS integration tests (notably, test important security properties)#1327
matthild wants to merge 6 commits into
grpc:masterfrom
matthild:matthild_tls_client_auth_test_v3

Conversation

@matthild

Copy link
Copy Markdown
Contributor

This pull request adds end-to-end tests of the following basic functionality:

  • A server configured to require client authentication refuses to accept connections from a client that has an untrusted certificate.
  • A server configured to require client authentication actually does require client authentication.
  • A client and a server configured using GrpcSslContexts can successfully communicate with each other. (This last test fails -- any idea why? For now I've annotated it @Ignore to avoid breaking the build.)

These tests work by having an actual GRPC client talk through the operating system's network stack to an actual GRPC server listening on a port, and thus mimic how GRPC will behave in real-world applications.

(I have also drafted tests of some other important security properties, but suggest adding them later via a separate pull request, once these initial tests are in place. The additional tests will be easier to add in a sensible way if some organization of the test certificates directory happens first.)

@grpc-kokoro

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@googlebot

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

The Travis build failed without it, and claimed that committing generated
files is necessary.
https://travis-ci.org/grpc/grpc-java/jobs/103388675
@matthild

Copy link
Copy Markdown
Contributor Author

That Travis CI build failed with an indication that interop-testing/src/generated/main/grpc/io/grpc/testing/integration/EchoServiceGrpc.java has been "modified" -- i.e., that the version of that file generated during the Travis build is different than the version that's in the repository. However, the version that's in the repository is bit-for-bit identical to the version that gradlew produces during a build, as shown below.

$ rm interop-testing/src/generated/main/grpc/io/grpc/testing/integration/EchoServiceGrpc.java

$ git status
On branch matthild_tls_client_auth_test_v3
Your branch is up-to-date with 'origin/matthild_tls_client_auth_test_v3'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    deleted:    interop-testing/src/generated/main/grpc/io/grpc/testing/integration/EchoServiceGrpc.java

no changes added to commit (use "git add" and/or "git commit -a")

$ ./gradlew build
# reports "BUILD SUCCESSFUL"

$ git status
On branch matthild_tls_client_auth_test_v3
Your branch is up-to-date with 'origin/matthild_tls_client_auth_test_v3'.
nothing to commit, working directory clean

Using ./gradlew assemble generateTestProto (which the Travis build uses) instead of ./gradlew build yields the same result.

Is there some trick to adding a new .proto file?

I'm running Mac OS X (El Capitan) and have protoc 3.0.0-beta1 installed (built locally).

$ protoc --version
libprotoc 3.0.0

@ejona86

ejona86 commented Jan 20, 2016

Copy link
Copy Markdown
Member

@matthild, the problem with EchoServiceGrpc.java confused me a lot too. I figured it out though: Travis tests the merged form of the change, so your generated file is lacking the changes from my recent commit d52429d. Rebasing on current master and regenerating EchoServiceGrpc.java should resolve the problem.

Thanks for working through all you have. I know it is a pain to get the codegen plugin compiling because of dependencies.

I'm thinking of ways that the error could have been a little more helpful. Maybe if it did git diff it would be more obvious that something unrelated had to have been at play.

Comment thread interop-testing/build.gradle Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmittler, this surprises me, mainly because I thought we already had the netty_tcnative dependency in place here. It seems we are including tcnative in the binaries (via the distributions section below) but was using Jetty ALPN during gradle build. Do you remember if we did not use tcnative here before because of concerns about needing OpenSSL installed, or was it something different?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, that was the outcome of our previous discussions ... that we wouldn't include tcnative in the automated tests due to the OpenSSL dependency. Not that configuring jetty-alpn is easier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GRPC docs recommend using OpenSSL. Are there any plans to have integration tests that use this recommended configuration?

The difference is significant. For example, removing libraries.netty_tcnative from build.gradle caused the new test annotated with @Ignore to begin passing -- i.e., that test appears to fail with OpenSSL but pass with Jetty ALPN. Additionally, there is a gaping security problem that appears to occur with OpenSSL but not with Jetty ALPN.

If we run all the tests using Jetty ALPN only, what should become of the following TODO in TlsTest.java? Should I just remove it?

// TODO: Use @RunWith(Parameterized.class) to run these tests for all TLS providers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I've reverted this change (thus, the integration tests run with Jetty ALPN only, not with OpenSSL), although personally I think there really ought to be integration tests that use the recommended configuration.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for starters, I do know of other tests that are using OpenSSL: the interop-testing unit tests are run internally at google using tcnative (I just confirmed). Tcnative is also used for the actual interop testing, both internally (I just confirmed) and externally (granted, those are a different sort of test).

I think the original plan was to use tcnative on Travis (because otherwise, why do a99e977?), but still allow small-time contributors to use Jetty ALPN. I know we hit a snag with OkHttp, because it only supports Jetty ALPN on OpenJDK and it couldn't talk to Netty on Linux because OpenSSL is generally too old to include ALPN. That's a different problem than on OS X and Windows, because on those platforms OpenSSL is generally not available and the code falls back to Jetty ALPN.

So for Linux we needed to check whether OpenSSL is new enough. But that was broken. I think once it was fixed we simply failed to follow through. Time to follow through; I've sent out #1332.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just filed #1330 for what I expect to be the same problem as here.

@ejona86

ejona86 commented Jan 21, 2016

Copy link
Copy Markdown
Member

@matthild LGTM. I'll merge it and then close the PR

@ejona86

ejona86 commented Jan 21, 2016

Copy link
Copy Markdown
Member

Cherry-picked as 95d7bfd. Thank you very much! That was quite involved.

With #1332 we hopefully are able to reliably trigger the problem, and investigate what is going wrong.

@ejona86 ejona86 closed this Jan 22, 2016
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants